package springjdbc;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.springframework.stereotype.Component;

@Component(value = "userDao")
public class UserDao extends JdbcDaoSupport {
	/*
	@Autowired
	private JdbcTemplate jdbcTemplate;
	*/
	@Autowired
	public void setJT(JdbcTemplate jdbcTemplate) {
		super.setJdbcTemplate(jdbcTemplate);
	}

	public void select() {
		JdbcTemplate template = this.getJdbcTemplate();
		List<Map<String,Object>> list = template.queryForList("select * from user");
		for (int i = 0; i < list.size(); i++) {
			Map<String, Object> map = list.get(i);
			System.out.println(map);
		}
	}
	
	public void test() {
		this.getJdbcTemplate().update("insert into user(username,password) values(?,?)","dgw","123");
	}

}
